﻿<div ms-controller="LIST">
    <div class="btn-add">
        <button type="button" ms-if="datatype=='3'&&JHDATA.JHStatus=='0'" class="btn btn-success btn-lg" ms-click="jhzxmx()"><i class=" iconfont icon-bianji ft12 mr5"></i>计划执行</button>

    </div>

    <div class="tab-filter-type">
        <div class="oh">
            <h5 class="pull-left tr">类型：</h5>
            <ul class="tab-type ft14">
                <li ms-click="SelectDataType('3')"><span class="active">待执行</span></li>
                <li ms-click="SelectDataType('5')"><span>已执行</span></li>
                <li ms-click="SelectDataType('4')"><span>已中止</span></li>


            </ul>
        </div>
    </div>

    <div class="default-tab ft14 pt20 grid">

        <div id="jqxgrid" class="jqxgrid" style="border-right: 0; border-left: 0;"></div>

    </div>
</div>

<script>


    var goption = {
        columns: [
               {
                   text: '', dataField: 'issel', columntype: 'checkbox', width: 40,
                   renderer: function () {
                           return '<div style="margin-left: 10px; margin-top: 5px;"></div>';
                       },
                   rendered: function (element) {
                           $(element).jqxCheckBox({ theme: "office", width: 16, height: 16, animationShowDelay: 0, animationHideDelay: 0 });
                           // columnCheckBox = $(element);
                           $(element).on('change', function (event) {
                               var checked = event.args.checked;
                               if (checked == null || false) return;
                               var rowscount = $("#jqxgrid").jqxGrid('getdatainformation').rowscount;
                               $("#jqxgrid").jqxGrid('beginupdate');

                               if (checked) {
                                   $("#jqxgrid").jqxGrid('selectallrows');
                               }
                               else if (checked == false) {
                                   $("#jqxgrid").jqxGrid('clearselection');
                               }

                               for (var i = 0; i < rowscount; i++) {
                                   $("#jqxgrid").jqxGrid('setcellvalue', i, 'issel', event.args.checked);
                               }

                               $("#jqxgrid").jqxGrid('endupdate');
                           });
                           return true;
                       }
               },
              { text: 'ID', dataField: 'ID', editable: false, hidden: "hides " },
              { text: '备注1', dataField: 'statusremark', hidden: "hides", editable: false },
              { text: '单位名称', dataField: 'dwname', editable: false },
              { text: '项目期别', dataField: 'Remark1', editable: false },
              { text: '计划科目', dataField: 'FLName', editable: false },
              { text: '产品类型', dataField: 'cplxname', editable: false },
              { text: '回款类型', dataField: 'hklxname', editable: false },
              { text: '金额小计', dataField: 'jexj', editable: false },
              { text: '第一月', dataField: 'je1', editable: false },
              { text: '第一月描述', dataField: 'je1dec', editable: false },
              { text: '备注', dataField: 'remark', editable: false },
              { text: '第一周', dataField: 'week1', editable: false },
              { text: '第二周', dataField: 'week2', editable: false },
              { text: '第三周', dataField: 'week3', editable: false },
              { text: '第四周', dataField: 'week4', editable: false },
              { text: '执行金额', dataField: 'zxje', editable: false },
              {
                  text: '计划状态', dataField: 'status', filterable: false, editable: false,
                  groupable: false, draggable: false, resizable: false, width: 100, cellsrenderer: function (row, column, value) {
                      var data = $('#jqxgrid').jqxGrid('getrowdata', row);
                      var desc = ComFunJS.jhsrstatus(data.status, data);
              
                      var html = "";
                      //html = '<a href="#" onclick="tempindex.showzt(\'' + row + '\')"><p class="text-error" style="display: inline;font-size: 16px;    color: blue;">' + desc + '</p></a>';
                      var returns = ' <div style="overflow: hidden; text-overflow: ellipsis; padding-bottom: 2px; text-align: left; margin-right: 2px; margin-left: 4px; margin-top: 12px;">' + desc + '</div>';
                      return returns;
                  }
              }
        ]
    };

    var tempindex = avalon.define({
        $id: "LIST",
        tmpListData: [],
        JHDATA: {},
        selids: "",
        datatype: "3",
        SelectDataType: function (type) {
            tempindex.datatype = type;
            tempindex.GetLIST();
        },
        InitWigetData: function (obj) {
            tempindex.JHDATA = model.JHDATA;
            //显示的列名
            tempindex.GetLIST();
            $(".tab-box li").each(function (i) {
                $(this).click(function () {
                    $(this).addClass("active").siblings().removeClass("active");
                    $("#wrap>div:eq(" + i + ")").show().siblings().hide();
                });
            });

        },
        getcheckid: function () {
            tempindex.selids = "";
            var rowindexes = $('#jqxgrid').jqxGrid('getselectedrowindexes');
            for (var i = 0; i < rowindexes.length; i++) {
                var data = $('#jqxgrid').jqxGrid('getrowdata', rowindexes[i]);
                if (i == 0) {
                    tempindex.selids = data.ID;
                } else {
                    tempindex.selids = tempindex.selids + "," + data.ID;

                }
            }
            return tempindex.selids;
        },
      
        jhzxmx: function () {
            if (!tempindex.getcheckid()) {
                ComFunJS.winwarning("请至少选择一条数据进行操作！");
                return;
            };
            if (tempindex.selids.toString().split(",").length > 1) {
                ComFunJS.winwarning("只能选择一条数据进行操作！");
                return;
            };
            ComFunJS.winviewform("/ViewV5/AppPage/JHZX/ZXMX.html?JHID=" + tempindex.JHDATA.ID + "&MXID=" + tempindex.selids + "&r=" + Math.random(), "计划执行");

        },
        GetLIST: function () {
            try {
                $('#jqxgrid').jqxGrid('destroy');

            } catch (e) {
            }
            $(".grid").append('<div id="jqxgrid" class="jqxgrid" style="border-right:0;border-left:0;"></div>')
            $.getJSON('/API/VIEWAPI.ashx?Action=JHZX_GETJHMXLIST', { P1: tempindex.JHDATA.ID, P2: tempindex.datatype }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    for (var i = 0; i < resultData.Result.length; i++) {
                        resultData.Result[i].issel = "false";
                    }
                     ComFunJS.inithighgrid(goption, resultData.Result, "jqxgrid");
                    tempindex.tmpListData = resultData.Result;
                }
            })
        }
    }) //@ sourceURL=JHSR_MXLIST.js;
</script>
